package com.wish;

/**
 * @Author: suliucheng
 * @Time: 2021/5/30 003010:44
 * @Description: 双重检查懒汉式加载单例模式
 */
public class Demo03Singleton {
    private Demo03Singleton() {
    }

    private static volatile Demo03Singleton instance;

    public static Demo03Singleton getInstance() {
        if (instance == null) {
            synchronized (Demo03Singleton.class) {
                if (instance == null) {
                    instance = new Demo03Singleton();
                }
            }
        }
        return instance;
    }
}
